﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DimensionData.Data2
{
    public class DMockData
    {
        public static DData GetData(DTable table)
        {
            DData data = new DData();
            if (table.Code == "WOW")
            {
                DDataNode p1 = new DDataNode() { Code = "P01", Name = "职业", Formula = "#P0101#+#P0102#+#P0103#" };
                p1.AddNode(new DDataNode() { Code = "P0101", Name = "近战" });
                p1.AddNode(new DDataNode() { Code = "P0102", Name = "远程" });
                p1.AddNode(new DDataNode() { Code = "P0103", Name = "治疗" });
                DDataNode p2 = new DDataNode() { Code = "P02", Name = "性别比列", Formula = "#P0201#/#P0202#" };
                p2.AddNode(new DDataNode() { Code = "P0201", Name = "男" });
                p2.AddNode(new DDataNode() { Code = "P0202", Name = "女" });
                data.Nodes.Add(p1);
                data.Nodes.Add(p2);
            }
            else if (table.Code == "D1")
            {
                data.Nodes.Add(new DDataNode() { Code = "T01", Name = "维度01" });

                DDataNode d2 = new DDataNode() { Code = "T02", Name = "维度02" };
                data.Nodes.Add(d2);
                d2.AddNode(new DDataNode() { Code = "T0201", Name = "维度05" });
                d2.AddNode(new DDataNode() { Code = "T0202", Name = "维度06" });
                d2.AddNode(new DDataNode() { Code = "T0203", Name = "维度07" });

                data.Nodes.Add(new DDataNode() { Code = "T03", Name = "维度03" });
                data.Nodes.Add(new DDataNode() { Code = "T04", Name = "维度04" });
            }
            else if (table.Code == "WEEK")
            {
                data.Nodes.Add(new DDataNode() { Code = "T01", Name = "星期一" });
                data.Nodes.Add(new DDataNode() { Code = "T02", Name = "星期二" });
                data.Nodes.Add(new DDataNode() { Code = "T03", Name = "星期三" });
                data.Nodes.Add(new DDataNode() { Code = "T04", Name = "星期四" });
                data.Nodes.Add(new DDataNode() { Code = "T05", Name = "星期五" });
                data.Nodes.Add(new DDataNode() { Code = "T06", Name = "星期六" });
                data.Nodes.Add(new DDataNode() { Code = "T07", Name = "星期日" });
            }
            else if (table.Code == "A")
            {
                data.Nodes.Add(new DDataNode() { Code = "T01", Name = "A" });
                data.Nodes.Add(new DDataNode() { Code = "T02", Name = "B" });
            }
            else if (table.Code == "DC.KM")
            {
                DDataNode p1 = new DDataNode() { 
                    Code = "DCKM01", 
                    Name = "开发成本",
                    Formula = "#DCKM0101#+#DCKM0102#+#DCKM0103#+#DCKM0104#+#DCKM0105#+#DCKM0106#+#DCKM0107#+#DCKM0108#+#DCKM0109#"
                };
                p1.AddNode(new DDataNode() { Code = "DCKM0101", Name = "土地成本" });
                p1.AddNode(new DDataNode() { Code = "DCKM0102", Name = "前期工程费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0103", Name = "建筑安装工程费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0104", Name = "基础设施费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0105", Name = "配套设施费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0106", Name = "不可预见费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0107", Name = "物业启动费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0108", Name = "开发间接费" });
                p1.AddNode(new DDataNode() { Code = "DCKM0109", Name = "资本化利息" });
                data.Nodes.Add(p1);
            }
            else if (table.Code == "DC.QJ")
            {
                DDataNode p1 = new DDataNode()
                {
                    Code = "DCQJ01",
                    Name = "本年合计"
                };
                DDataNode p11 = new DDataNode()
                {
                    Code = "DCQJ0101",
                    Name = "一季度",
                    Formula = "#DCQJ010101#+#DCQJ010102#+#DCQJ010103#"
                };
                p1.AddNode(p11);
                p11.AddNode(new DDataNode() { Code = "DCQJ010101", Name = "一月" });
                p11.AddNode(new DDataNode() { Code = "DCQJ010102", Name = "二月" });
                p11.AddNode(new DDataNode() { Code = "DCQJ010103", Name = "三月" });
                DDataNode p12 = new DDataNode()
                {
                    Code = "DCQJ0102",
                    Name = "二季度",
                    Formula = "#DCQJ010201#+#DCQJ010202#+#DCQJ010203#"
                };
                p1.AddNode(p12);
                p12.AddNode(new DDataNode() { Code = "DCQJ010201", Name = "四月" });
                p12.AddNode(new DDataNode() { Code = "DCQJ010202", Name = "五月" });
                p12.AddNode(new DDataNode() { Code = "DCQJ010203", Name = "六月" });
                DDataNode p13 = new DDataNode()
                {
                    Code = "DCQJ0103",
                    Name = "三季度",
                    Formula = "#DCQJ010301#+#DCQJ010302#+#DCQJ010303#"
                };
                p1.AddNode(p13);
                p13.AddNode(new DDataNode() { Code = "DCQJ010301", Name = "七月" });
                p13.AddNode(new DDataNode() { Code = "DCQJ010302", Name = "八月" });
                p13.AddNode(new DDataNode() { Code = "DCQJ010303", Name = "九月" });
                DDataNode p14 = new DDataNode()
                {
                    Code = "DCQJ0104",
                    Name = "四季度",
                    Formula = "#DCQJ010401#+#DCQJ010402#+#DCQJ010403#"
                };
                p1.AddNode(p14);
                p14.AddNode(new DDataNode() { Code = "DCQJ010401", Name = "十月" });
                p14.AddNode(new DDataNode() { Code = "DCQJ010402", Name = "十一月" });
                p14.AddNode(new DDataNode() { Code = "DCQJ010403", Name = "十二月" });
                data.Nodes.Add(p1);
            }
            else if (table.Code == "DC.CBI")
            {
                data.Nodes.Add(new DDataNode() { Code = "DCCBI01", Name = "总成本" });
                data.Nodes.Add(new DDataNode() { Code = "DCCBI02", Name = "结转率（%）", Formula = "#DCCBI03#/#DCCBI01#" });
                data.Nodes.Add(new DDataNode() { Code = "DCCBI03", Name = "营业成本" });
            }
            else if (table.Code == "DC.PROJ")
            {
                data.Nodes.Add(new DDataNode() { Code = "DCPROJ01", Name = "地产项目一" });
                data.Nodes.Add(new DDataNode() { Code = "DCPROJ02", Name = "地产项目二" });
                data.Nodes.Add(new DDataNode() { Code = "DCPROJ03", Name = "地产项目三" });
            }
            else if (table.Code == "JR.KM")
            {
                data.Nodes.Add(new DDataNode() { Code = "JRKM01", Name = "营业收入" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM02", Name = "营业成本" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM03", Name = "营业毛利" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM04", Name = "直接营业费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM05", Name = "直接营业毛利" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM06", Name = "间接营业费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM07", Name = "营业税金及附加" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM08", Name = "财务费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM09", Name = "贡献毛利" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM10", Name = "管理费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM11", Name = "资产减值损失" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM12", Name = "公允价值变动收益" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM13", Name = "投资收益" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM14", Name = "营业利润" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM15", Name = "营业外收入" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM16", Name = "营业外支出" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM17", Name = "利润总额" });
            }
            else if (table.Code == "JR.QJ")
            {
                data.Nodes.Add(new DDataNode() { Code = "JRQJ01", Name = "上年1-9月实际" });
                data.Nodes.Add(new DDataNode() { Code = "JRQJ02", Name = "上年10-12月预测" });
                data.Nodes.Add(new DDataNode() { Code = "JRQJ03", Name = "上年全年预测" });
                data.Nodes.Add(new DDataNode() { Code = "JRQJ04", Name = "上年全年预算" });
                DDataNode p1 = new DDataNode() { Code = "JRQJ05", Name = "本年合计" };
                data.Nodes.Add(p1);
                DDataNode p11 = new DDataNode() { Code = "JRQJ0501", Name = "一季度" };
                p1.AddNode(p11);
                p11.AddNode(new DDataNode() { Code = "JRQJ050101", Name = "一月" });
                p11.AddNode(new DDataNode() { Code = "JRQJ050102", Name = "二月" });
                p11.AddNode(new DDataNode() { Code = "JRQJ050103", Name = "三月" });
                DDataNode p12 = new DDataNode() { Code = "JRQJ0502", Name = "二季度" };
                p1.AddNode(p12);
                p12.AddNode(new DDataNode() { Code = "JRQJ050201", Name = "四月" });
                p12.AddNode(new DDataNode() { Code = "JRQJ050202", Name = "五月" });
                p12.AddNode(new DDataNode() { Code = "JRQJ050203", Name = "六月" });
                DDataNode p13 = new DDataNode() { Code = "JRQJ0503", Name = "三季度" };
                p1.AddNode(p13);
                p13.AddNode(new DDataNode() { Code = "JRQJ050301", Name = "七月" });
                p13.AddNode(new DDataNode() { Code = "JRQJ050302", Name = "八月" });
                p13.AddNode(new DDataNode() { Code = "JRQJ050303", Name = "九月" });
                DDataNode p14 = new DDataNode() { Code = "JRQJ0504", Name = "四季度" };
                p1.AddNode(p14);
                p14.AddNode(new DDataNode() { Code = "JRQJ050401", Name = "十月" });
                p14.AddNode(new DDataNode() { Code = "JRQJ050402", Name = "十一月" });
                p14.AddNode(new DDataNode() { Code = "JRQJ050403", Name = "十二月" });
            } 
            else if(table.Code == "JR.BIZ")
            {
                data.Nodes.Add(new DDataNode() { Code = "JRBIZ01", Name = "医疗板块" });
                data.Nodes.Add(new DDataNode() { Code = "JRBIZ02", Name = "印刷板块" });
                data.Nodes.Add(new DDataNode() { Code = "JRBIZ03", Name = "船运板块" });
            }
            else
            {
                data.Nodes.Add(new DDataNode() { Code = "JRKM01", Name = "营业收入" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM02", Name = "营业成本" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM03", Name = "营业毛利" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM04", Name = "直接营业费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM05", Name = "直接营业毛利" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM06", Name = "间接营业费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM07", Name = "营业税金及附加" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM08", Name = "财务费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM09", Name = "贡献毛利" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM10", Name = "管理费用" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM11", Name = "资产减值损失" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM12", Name = "公允价值变动收益" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM13", Name = "投资收益" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM14", Name = "营业利润" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM15", Name = "营业外收入" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM16", Name = "营业外支出" });
                data.Nodes.Add(new DDataNode() { Code = "JRKM17", Name = "利润总额" });
            }
            return data;
        }

        public static List<DDataRelation> GetDRelation(string docCode)
        {
            List<DDataRelation> relations = new List<DDataRelation>();

            if (docCode == "DC")
            {
                // 1season
                relations.Add(new DDataRelation(docCode, "DCQJ0101", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ0101", "DCCBI03"));

                //1-3month
                relations.Add(new DDataRelation(docCode, "DCQJ010101", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010101", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010102", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010102", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010103", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010103", "DCCBI03"));

                //2 season
                relations.Add(new DDataRelation(docCode, "DCQJ0102", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ0102", "DCCBI03"));

                //4-6 month
                relations.Add(new DDataRelation(docCode, "DCQJ010201", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010201", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010202", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010202", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010203", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010203", "DCCBI03"));

                // 3 season
                relations.Add(new DDataRelation(docCode, "DCQJ0103", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ0103", "DCCBI03"));

                //8-9month
                relations.Add(new DDataRelation(docCode, "DCQJ010301", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010301", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010302", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010302", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010303", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010303", "DCCBI03"));

                // 4season
                relations.Add(new DDataRelation(docCode, "DCQJ0104", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ0104", "DCCBI03"));

                //11-12month
                relations.Add(new DDataRelation(docCode, "DCQJ010401", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010401", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010402", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010402", "DCCBI03"));
                relations.Add(new DDataRelation(docCode, "DCQJ010403", "DCCBI02"));
                relations.Add(new DDataRelation(docCode, "DCQJ010403", "DCCBI03"));
            }

            return relations;
        }

        /// <summary>
        /// 获取文档引用关系，这里的doccode是文档模板的编号，而非具体的某一个文档
        /// </summary>
        /// <param name="docCode"></param>
        /// <returns></returns>
        public static List<DataRefRule> GetDataRefs(string docCode)
        {
            List<DataRefRule> dataRefs = new List<DataRefRule>();
            if (docCode == "JR")
            {
                //1-3月
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050101"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050101")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050102"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050102")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050103"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050103")
                });
                //4-6月
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050201"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050201")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050202"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050202")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050203"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050203")
                });
                //7-9月
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050301"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050301")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050302"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050302")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050303"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050303")
                });
                //10-12月
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050401"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050401")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050402"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050402")
                });
                dataRefs.Add(new DataRefRule()
                {
                    DestDocCode = docCode,
                    DestPathExpression = new PathExpression(@"\*\JRKM01\JRQJ050403"),
                    SourceDocCode = "JRM",
                    SourcePathExpression = new PathExpression(@"\*\JRKM01\JRQJ050403")
                });
            }
            return dataRefs;
        }

        public static List<FormulaRule> GetFormulaRules(string docCode)
        {
            List<FormulaRule> rules = new List<FormulaRule>();
            if (docCode == "DC")
            {
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\DCKM01\*\*",
                    FormulaExpression = @"#\*\DCKM0101\*\*#+#\*\DCKM0102\*\*#+#\*\DCKM0103\*\*#+#\*\DCKM0104\*\*#+#\*\DCKM0105\*\*#+#\*\DCKM0106\*\*#+#\*\DCKM0107\*\*#+#\*\DCKM0108\*\*#+#\*\DCKM0109\*\*#"
                });
                // 本年合计的营业成本=个季度营业成本之和
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ01\DCCBI03",
                    FormulaExpression = @"#\*\*\DCQJ0101\DCCBI03#+#\*\*\DCQJ0102\DCCBI03#+#\*\*\DCQJ0103\DCCBI03#"
                });
                // 本年合计的结转率=营业成本/总成本
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ01\DCCBI02",
                    FormulaExpression = @"#\*\*\DCQJ01\DCCBI03#/#\*\*\DCQJ01\DCCBI01#"
                });
                // 季度营业成本=个月度营业成本之和
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0101\DCCBI03",
                    FormulaExpression = @"#\*\*\DCQJ010101\DCCBI03#+#\*\*\DCQJ010102\DCCBI03#+#\*\*\DCQJ010103\DCCBI03#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0102\DCCBI03",
                    FormulaExpression = @"#\*\*\DCQJ010201\DCCBI03#+#\*\*\DCQJ010202\DCCBI03#+#\*\*\DCQJ010203\DCCBI03#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0103\DCCBI03",
                    FormulaExpression = @"#\*\*\DCQJ010301\DCCBI03#+#\*\*\DCQJ010302\DCCBI03#+#\*\*\DCQJ010303\DCCBI03#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0104\DCCBI03",
                    FormulaExpression = @"#\*\*\DCQJ010401\DCCBI03#+#\*\*\DCQJ010402\DCCBI03#+#\*\*\DCQJ010403\DCCBI03#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0101\DCCBI02",
                    FormulaExpression = @"#\*\*\DCQJ0101\DCCBI03#/#\*\*\DCQJ01\DCCBI01#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0102\DCCBI02",
                    FormulaExpression = @"#\*\*\DCQJ0102\DCCBI03#/#\*\*\DCQJ01\DCCBI01#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0103\DCCBI02",
                    FormulaExpression = @"#\*\*\DCQJ0103\DCCBI03#/#\*\*\DCQJ01\DCCBI01#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\DCQJ0104\DCCBI02",
                    FormulaExpression = @"#\*\*\DCQJ0104\DCCBI03#/#\*\*\DCQJ01\DCCBI01#"
                });
                // 季度和月份的营业成本=本年合计*结转率
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\*\DCCBI03",
                    FormulaExpression = @"#\*\*\DCQJ01\DCCBI01#*#\*\*\*\DCCBI02#"
                });
            }
            else if (docCode == "JR")
            {
                // 营业毛利=营业收入-营业成本
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\JRKM03\*",
                    FormulaExpression = @"#\*\JRKM01\*#-#\*\JRKM02\*#"
                });
                // 营业直接毛利=营业收入-营业成本
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\JRKM05\*",
                    FormulaExpression = @"#\*\JRKM03\*#-#\*\JRKM04\*#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\JRKM09\*",
                    FormulaExpression = @"#\*\JRKM05\*#-#\*\JRKM06\*#-#\*\JRKM07\*#-#\*\JRKM08\*#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\JRKM14\*",
                    FormulaExpression = @"#\*\JRKM09\*#-#\*\JRKM10\*#-#\*\JRKM11\*#-#\*\JRKM12\*#-#\*\JRKM13\*#"
                });
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\JRKM17\*",
                    FormulaExpression = @"#\*\JRKM14\*#+#\*\JRKM15\*#-#\*\JRKM16\*#"
                });

                // 上年全年预测
                rules.Add(new FormulaRule()
                {
                    TargetExpression = @"\*\*\JRQJ03",
                    FormulaExpression = @"#\*\*\JRQJ01#+#\*\*\JRQJ02#"
                });
            }
            return rules;
        }
    }
}
